package com.itheima.demo;
import javax.swing.*;
public class CookingCommand {
	public static void main(String[] args) {
		Breakfast food1=new ChangFen();
		Waiter fwy=new Waiter();
		fwy.setChangFen(food1);//设置肠粉菜单
		fwy.chooseChangFen();  //选择肠粉

	}
}
//调用者：服务员
class Waiter
{
	private Breakfast changFen;
	public void setChangFen(Breakfast f)
	{
		changFen=f;
	}
	public void chooseChangFen()
	{
		changFen.cooking();
	}

}
//抽象命令：早餐
interface Breakfast
{
	public abstract void cooking();
}
//具体命令：肠粉
class ChangFen implements Breakfast
{
	private ChangFenChef receiver;
	ChangFen(){
		receiver=new ChangFenChef();
	}
	public void cooking()
	{		
		receiver.cooking();
	}
}

//接收者：肠粉厨师
class ChangFenChef extends JFrame
{	
	private static final long serialVersionUID = 1L;
	JLabel l=new JLabel();
	ChangFenChef(){
		super("煮肠粉");
		l.setIcon(new ImageIcon("hystrix-client/src/main/resources/ChangFen.jpg"));
		this.add(l);
		this.setLocation(30, 30);
        this.pack();        		       
	    this.setResizable(false);
	    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
	    
	}   	
	public void cooking()
	{
		this.setVisible(true); 
	}
}
